package com.src.myapplication.ui.view.fragmentzhibo;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.google.gson.Gson;
import com.src.myapplication.R;
import com.src.myapplication.base.BaseFragmentSwp;
import com.src.myapplication.bean.MingXingben;
import com.src.myapplication.config.UrlConfig;
import com.src.myapplication.widget.CommonAdapter;
import com.src.myapplication.widget.base.ViewHolder;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/10/17.
 */
public class MingXing extends BaseFragmentSwp {

    public RecyclerView mRcv;

    @Override
    protected void initData(View view) {
        mRcv = (RecyclerView) view.findViewById(R.id.rcv);
    }

    @Override
    public int getLayoutId() {
        return R.layout.fragment_mingxing;
    }


    @Override
    public int getid() {
        return R.id.sw;
    }

    @Override
    public String geturl() {
        return UrlConfig.ZhiBo.ZHIBO_FUJIN_MINGXING;
    }


    @Override
    public Class<?> getben() {
        return MingXingben.class;
    }

    @Override
    public void addList(String string) {
        if (string != null) {

            Gson gson=new Gson();
            List<MingXingben> listBean=new ArrayList<>();
            MingXingben mingXingben = gson.fromJson(string, MingXingben.class);
            List<MingXingben.InfoBean.LivelistBean> livelist1 = mingXingben.getInfo().getLivelist();
            listBean.add(mingXingben);

            CommonAdapter<MingXingben.InfoBean.LivelistBean> adapter=new CommonAdapter<MingXingben.InfoBean.LivelistBean>(getContext(),R.layout.fragment_mingxing_list,livelist1) {
                @Override
                protected void convert(ViewHolder holder, MingXingben.InfoBean.LivelistBean listBean, int position) {

                    String avatar = listBean.getCover();
                    String sign = listBean.getUser().getSign();
                    SimpleDraweeView view1 = holder.getView(R.id.sdv);
                    TextView view = holder.getView(R.id.tv);
                    view.setText(sign);
                    view1.setImageURI(avatar);
                }
            };
            LinearLayoutManager manager=new LinearLayoutManager(getContext());
            manager.setOrientation(LinearLayoutManager.VERTICAL);
            mRcv.setLayoutManager(manager);
            mRcv.setAdapter(adapter);

        }
    }
    @Override
    public void showLoadFailMsg() {

    }
}